<template xmlns="http://www.w3.org/1999/html">
  <sea-data-table ref="tableObject" url="/sys/image/page">
    <!--表头-->
    <sea-table-header slot="header">
      <!--标题栏-->
      <sea-table-title slot="title" title="图片管理" subtitle=""></sea-table-title>

      <!--按钮栏-->
      <template slot="buttons">
        <el-button plain size="small" title="新增" icon="fa fa-plus" @click="onAction('new')"></el-button>
      </template>
    </sea-table-header>

    <!--表头-->
    <template slot="columns">
      <sea-col-link property="imagePath" label="相对路径" :click="onAction"></sea-col-link>
      <el-table-column property="imageName" label="原名" width="180"></el-table-column>
      <el-table-column property="extension" label="扩展名" width="180"></el-table-column>
      <el-table-column property="imageSize" label="文件大小" width="180"></el-table-column>
      <el-table-column property="imageType" label="文件类型" width="180"></el-table-column>
      <el-table-column property="gmtCreate" label="创建日期" width="180"></el-table-column>
      <el-table-column property="gmtModified" label="更新日期" width="180"></el-table-column>

      <!--操作栏-->
      <sea-table-actionbar width="180" :on-action="onAction" :buttons="buttons"></sea-table-actionbar>
    </template>
  </sea-data-table>
</template>

<script>

export default {
    components: {},
    data() {
        return {
            // 操作名称
            operation: undefined
            // 当前操作的行级对象
            , row_data: undefined
            // 操作栏
            , buttons: [
                {type: 'btn', evt: 'info', label: '查看', title: '查看文件上传之后的数据导入情况'}
                , {type: 'divider'}
                , {type: 'btn', evt: 'remove', label: '删除', style: 'text-orange', title: '删除当前行'}
            ]
            // end--
        }
    },
    methods: {
        /**
         * 操作成功回调
         */
        onSucceed: function () {
            this.$refs.tableObject.reload();
        },
        /**
         * 操作栏事件分发
         * @param evt 事件
         * @param row 行级对象
         * @param old 可供回滚的参数
         */
        onAction: function (evt, row, old) {
            if (evt === '$imagePath' || evt === 'info') {
                this.$layers.downloadFile('/sys/image/download/' + row.id)
            } else if (evt === 'remove') {
                // do nothing
            } else {
                this.$refs.panel.onAction(evt, row)
            }
        }
    }
}
</script>
